package com.ljt.yupictureddd.domain.space.valueobject;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

import java.util.Arrays;

@Getter
public enum SpaceTypeEnums {

    PRIVATE("私有",0),

    TEAM("团队", 1);



    private final String text;

    private final int value;


    SpaceTypeEnums(String text, int value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据value获取枚举
     *
     * @param value
     * @return
     */
    public static SpaceTypeEnums getEnumByValue(int value) {
        if (ObjUtil.isEmpty(value)) {
            return null;
        }
        SpaceTypeEnums userRoleEnums = Arrays.stream(SpaceTypeEnums.values())
                .filter(space -> space.getValue() == value)
                .findFirst()
                .get();
        return userRoleEnums;
    }
}
